﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Process.Api.Application.Command;
using Process.DAL;
using Process.ErrorCod;
using Process.Model;
using ProcessDto;

namespace Process.Api.Controllers
{
    /// <summary>
    /// 工序服务
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProcessController : ControllerBase
    {
        private readonly IMediator mediator;

        public ProcessController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 工序分类新增
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public async Task<ApiResult<int>> AddProcessType(AddProcessTypeCommand request)
        {
            return await mediator.Send(request);  
        }
        /// <summary>
        /// 查询工序分类分页数据
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public async Task<ApiPageing<ProcessType>> ShowProcessType([FromQuery]ShowProcessTypeCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 工序分类删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public async Task<ApiResult<int>> DelProcesssType(DeleteProcessTypeCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
		/// 根据Id查询工序分类
		/// </summary>
        [HttpGet]
		public Task<ApiResult<ProcessType>> ProcessTypeDetail([FromQuery]DetailProcessTypeCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 修改工序分类
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public async Task<ApiResult<int>> UpdateProcessType(UpdateProcessTypeCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 工序新增
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public async Task<ApiResult<int>> AddProcessinfo(AddProcessinfoCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 获取工序管理列表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public Task<ApiPageing<ProcessInfoDto>> ShowProcessinfo([FromQuery]ShowProcessinfoCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 删除工序数据
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public async Task<ApiResult<int>> DelProcessinfo(DeleteProcessinfoCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 根据Id查询工序列表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<Processinfo>> ProcessInfoDetail([FromQuery]DetailProcessinfoCommand request)
        {
             return mediator.Send(request);
        }
        /// <summary>
        /// 更新工序数据
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public async Task<ApiResult<int>> UpdateProcessinfo(UpdateProcessCommand request)
        {
            return await mediator.Send(request);
        }

    }
}
